<?php

/**
 * +---------------------------------------------------------------
 * | Author: 北京永青宇创科技有限公司
 * | Date: 2020/03/12
 * | 版本: 6.0
 * +---------------------------------------------------------------
 * | CopyRight: 北京永青宇创科技有限公司 All rights reserved.
 * +---------------------------------------------------------------
 * | 版权声明：云豹不是一个自由软件，是云豹官方推出的商业源码。
 * | 严禁在未经许可的情况下拷贝、复制、传播、使用云豹的任意代码
 * | 如有违反，请立即删除，否则您将面临承担相应，法律责任的风险。
 * | 如果需要取得官方授权，请联系官方 https://www.gepardshop.com
 * +---------------------------------------------------------------
 */

namespace app\mall\controller\connect;

use think\Controller;

class SiteMap extends Controller {
	protected $options     = [
		'item_key'  => '',
		'root_node' => 'urlset',
		'item_node' => 'url',
		'root_attr' => 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:mobile="http://www.baidu.com/schemas/sitemap-mobile/1/"',
	];
	public function Index($page = 1)
	{
		$map     = [];
		$type    = 'mall/mallGoods';
		$newlist = model('seo/seo')->newsByPage($type, $map, $page, 'update_time desc,create_time desc', '*', 3000);

		$content_xml = [];

		foreach($newlist[0] as $key => $valu) {
			$content_xml[$key]['loc']   = url('mall/Index/Detail', ['id' => $valu['id']], true, true);
			$content_xml[$key]['lastmod'] = time_format($valu['update_time'] ? $valu['update_time'] : $valu['create_time'],'Y-m-d H:i');;
			$content_xml[$key]['priority']=0.6;
			$content_xml[$key]['changefreq']='daily';
		}

		return xml($content_xml, 200, [], $this->options);

	}
}